<template>
    <mescroll-uni
        ref="mescrollRef"
        @init="mescrollInit"
        :height="height"
        :down="downOption"
        @down="downRefresh"
        :up="upOption"
        @up="getData">
        <order-item
            v-for="(item, index) in datas"
            :key="index"
            :selectData="selectData"
            @changeCheck="changeCheck"
            @showSnewm="showSnewm"
            :data="item"></order-item>
    </mescroll-uni>
</template>
<script>
import orderItem from "./order-item.vue"
import { getSortingOrderPage } from "@/service/api/communtiyGroup.js"
export default {
    props: {
        height: {
            type: String,
            default: "100px",
        },
        orderId: {
            type: String,
            default: "",
        },
        requestData: {
            type: Object,
            default: {},
        },
        selectData: {
            type: Array,
            default() {
                return []
            },
        },
    },
    components: {
        orderItem,
    },
    watch: {
        requestData(newVal, oldVal) {
            this.param = newVal
        },
    },
    data() {
        return {
            datas: [],
            param: {
                userType: 1,
            },
            downOption: {
                use: true,
            },
        }
    },
    mounted() {
        //#ifndef MP
        this.refresh(this.requestData)
        //#endif
    },
    methods: {
        //获取列表数据
        getData(page) {
            let param = this.param
            param.pageSize = 999
            param.pageIndex = page.num
            param.sortingId = this.orderId
            getSortingOrderPage(param).then((res) => {
                if (res.State == 1) {
                    this.mescroll.endBySize(res.Data.length, res.RecordAmout)
                    this.datas = this.datas.concat(res.Data)
                    this.$emit("changeData", this.datas)
                } else {
                    this.mescroll.endBySize(0, 0)
                }
            })
        },
        //刷新
        refresh(requestData) {
            this.downRefresh(requestData, true)
        },
        showSnewm(item) {
            this.$emit("showSnewm", item)
        },
        //刷新
        downRefresh(requestData, isSetParam = false) {
            this.datas = []
            if (isSetParam) {
                this.param = requestData
            }
            this.mescroll.resetUpScroll()
        },
        changeCheck(e) {
            this.$emit("changeCheck", e)
        },
    },
}
</script>

<style lang="scss"></style>
